<!-- 会员管理 -->
<template>
  <div class="page-box h100 display-flex czbj">
    <div class="title-label mb10 display-flex">
      会员管理 <span class="ml20 red">平台币总额：{{ jdsfsdf }}</span>

      <div class="ml100">
      默认注册会员：
      <n-radio-group @change="dsfsftrtrt" v-model:value="dfsddft" name="radiogroup">
        <n-space>
          <n-radio  value="1">
           普通会员
          </n-radio>
          <n-radio  value="2">
           VIP
          </n-radio>
        </n-space>
      </n-radio-group>
    </div>
    </div>
   
    <!-- sonRouter="yybureauFormationBJ" 为跳转新的页面编辑平台币 -->
    <dxtable
      :dataJson="dataJson"
      :portUrl="portUrl"
      :hidebj="true"
      :formJson="formJson"
      :qx="qx"
      accept=".jpg,.png,,.jpeg,.mp4,.m4v"
      ref="databale"
    ></dxtable>
  </div>
</template>
<script lang="ts" setup>
import dxtable from "../../components/util/dxtable.vue";
import sort from "../../components/util/sort.vue";
import { dxget, dxpost } from "../../util/index";
import { NButton, NImage, NTag, NSwitch } from "naive-ui";
import { h, ref, reactive, render } from "vue";
import uxiala from "./components/uxiala.vue";
const databale = ref();
const jdsfsdf = ref();
const dfsddft= ref()

const jhdfdgg = async () => {
  const { data }: any = await dxget("jyc/api/getptb");
  jdsfsdf.value = data;
  if (data == null) {
    jdsfsdf.value = 0;
  }

  dataJson[9].title = "当前平台币总数(" + jdsfsdf.value + ")";
};
jhdfdgg();
const initeer = () => {
  databale.value.initDataExpose();
  jhdfdgg();
};
const portUrl = "jyc/userList/userList";
let dataJson = [
  {
    title: "id",
    key: "id",
    width: 80,
  },
  {
    title: "姓名",
    key: "name",
    search: true,
  },
  {
    title: "是否为VIP",
    key: "dengji",
    render: (row) => {
      let jdfds = 2;
      return [
        h(NSwitch, {
          "default-value": row.dengji == 2 ? true : false,
          "on-update:value": async (e) => {
            if (row.dengji == 2) {
              jdfds = 1;
            }
            await dxpost(portUrl, { id: row.id, dengji: jdfds }, "put");
          },
        }),
      ];
    },
  },
  {
    title: "是否禁用",
    key: "isjy",
    render: (row) => {
      let jdfds = 2;
      return [
        h(NSwitch, {
          "default-value": row.isjy == 2 ? true : false,
          "on-update:value": async (e) => {
            if (row.isjy == 2) {
              jdfds = 1;
            }
            await dxpost(portUrl, { id: row.id, isjy: jdfds }, "put");
          },
        }),
      ];
    },
  },
  {
    title: "是否禁言",
    key: "jinyan",
    render: (row) => {
      let jdfds = 2;
      return [
        h(NSwitch, {
          "default-value": row.jinyan == 2 ? true : false,
          "on-update:value": async (e) => {
            if (row.jinyan == 2) {
              jdfds = 1;
            }
            await dxpost(portUrl, { id: row.id, jinyan: jdfds }, "put");
          },
        }),
      ];
    },
  },
  {
    title: "电话",
    key: "phone",
  },
  {
    title: "邮箱",
    key: "email",
  },
  {
    title: "身份证号码",
    key: "idCard",
  },
  {
    title: "收款账号",
    key: "shoukuanzh",
  },
  {
    title: "当前平台币总数",
    key: "pingtaibi",
    width: 180,
    render(row) {
      return row.pingtaibi || "0.00";
    },
  },
  {
    title: "介绍人id",
    key: "superiorId",
    render(row) {
      return row.superiorId || "--";
    },
  },
  {
    title: "注册时间",
    key: "addTime",
    width: 150,
  },
  {
    title: "操作",
    render(row) {
      return h(uxiala, {
        dxdata: row,
        onCallback: function (data) {
          console.log("88888");
          console.log(data);
          initeer();
        },
      });
    },
  },
];

const qx = {
  DeletePermissionID: "jycuserListdel", //删除
  EditPermissionIdentifier: "23456", // 编辑
  NewPermissionIdentifier: "23456", // 新建
  ViewPermissionID: "jycuserListck", // 查看
};

let formJson = reactive([]);
const createSummary = (pageData) => {
  return [
    {
      value: 6,
      colSpan: 3,
      rowSpan: 1,
    },
  ];
};

const czFun = {
  fun: (row) => {
    return [
      h(
        NButton,
        {
          type: "info",
          quaternary: true,
          onClick: async (e) => {},
        },
        "复制代码"
      ),
    ];
  },
};

// 获取字典内容
const xtgxxmfl = async () => {
  const { data }: any = await dxget("dxgjAdmin/getzd", { name: 'dfsfdsf' })
  dfsddft.value = data
}
xtgxxmfl()
const dsfsftrtrt= async(a,b)=>{
  console.log(dfsddft.value);
  await dxpost("dxgjAdmin/dxDictionarymanagement",{
    id:488,
    text:dfsddft.value
  },"put")
}
</script>
<style scoped></style>
